#include<iostream>
using namespace std;
class Solution {
public:
    void trim(string &s){
        if(!s.empty()){
            s.erase(0, s.find_first_not_of(" "));
            s.erase(s.find_last_not_of(" ") + 1);
        }

    }
    int strToInt(string str) {
       double res = 0;
        int i = 0;
        bool sign = false;
        while(str[i] == ' ') i++;
        if(str[i] == '-' || str[i] == '+')
        {
            if(str[i] == '-') sign = true;
            i++;
        }
        while(str[i] >= '0' && str[i] <= '9')
        {
            res =  res * 10 + str[i] - '0';
            i++;        
        }
        res = (sign ? -res : res);
        if(res > INT_MAX) return INT_MAX;
            
        if(res < INT_MIN) return INT_MIN;
        
        return (int)res;


    }
};